<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/meroperation.css" />
<link rel="stylesheet" type="text/css" href="css/default/om-default.css" />
<link rel="stylesheet" type="text/css" href="css/grid-extra.css" />
<link rel="stylesheet" type="text/css" href="css/calendar-extra.css" />
<link rel="stylesheet" type="text/css" href="css/easydialog.css" />
<script type="text/javascript" src="js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/om-grid.js" charset="utf-8"></script>
<script type="text/javascript" src="js/om-calendar.js" charset="utf-8"></script>
<script type="text/javascript" src="js/easydialog.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/tools.js" charset="utf-8"></script>
<script src="js/util.js" type="text/javascript"></script>
<script type="text/javascript">

	var selectedpay =[];
	$(document).ready(function() {
         $('#mytable').omGrid({
             height : 250,
              width : 600,
              limit : 8, //分页显示，每页显示8条
              singleSelect : false, //出现checkbox列，可以选择同时多行记录
              colModel : [    {header:'编号',name:'id', width:100, align : 'center'},
                              {header:'地区',name:'city', width:250, align : 'left',wrap:true},
                              {header:'地址',name:'address', width:'autoExpand',renderer:function(value,rowData,rowIndex){ return '&lt;b>'+value+'&lt/b>'; }}
              ],
              dataSource : 'testdo', //后台取数的URL
              onRefresh : function(nowpage, records){
					var len = selectedpay.length;
                    var indexs = [], index =-1;
                    for(var i=0; i<len; i++){
                           $.each(records, function(n,item){
                               if(item.id === selectedpay[i]){
                                         indexs.push(n);
                               }
                           });
                        }  
                    $("#mytable").omGrid("setSelections", indexs);
				},
				onRowSelect:function(rowIndex,rowData,event) {
					if($.inArray(rowData.id,selectedpay))
					{
						selectedpay.push(rowData.id);
					}
					
					
				},
				onRowDeselect:function(rowIndex,rowData,event) {
					var i = $.inArray(rowData.id,selectedpay);
					selectedpay.splice(i,1);
				},
          });
      });
	
	function btclk()
	{
		
		console.log(selectedpay);
	}
	
</script>
</head>
<body>
		<div id="mytable"></div>
		
		
		<input type="button" onclick="btclk()" value="sssss"/>
</body>
</html>